package org.bit.lesson01;

public class Demo04_Runnable {
    public static void main(String[] args) {
        // 实例化任务对象
        MyRunnable02 myRunnable02 = new MyRunnable02();
        MyRunnable03 myRunnable03 = new MyRunnable03();

        // 创建线程对象
        Thread thread01 = new Thread(myRunnable02); // 皮鞋1
        Thread thread02 = new Thread(myRunnable02); // 皮鞋2
        Thread thread03 = new Thread(myRunnable03); // 皮包1

        // 启动线程
        thread01.start();
        thread02.start();
        thread03.start();
    }
}

class MyRunnable02 implements Runnable {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("生产皮鞋，金币+20");
        }
    }
}

class MyRunnable03 implements Runnable {
    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("生产皮包，金币+50");
        }
    }
}
